package com.online.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.online.entity.Teacher;
import com.online.mapper.TeacherMapper;
import com.online.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    /**
     *查询所有的教师
     * @param
     * @param keyword
     * @return
     */
    @Override
    public IPage<Teacher> findAll(Page<Teacher> page, String keyword) {
        if (keyword != null && !keyword.isEmpty()) {
            return teacherMapper.findAllWithKeyword(page, keyword);
        } else {
            return teacherMapper.findAll(page);
        }
    }
    /**
     * 根据id查询教师
     * @param teacherId
     * @return
     */
    @Override
    public Teacher findById(Integer teacherId) {
        return teacherMapper.findById(teacherId);
    }

    /**
     * 根据id删除教师
     * @param teacherId
     * @return
     */
    @Override
    public int deleteById(Integer teacherId) {
        return teacherMapper.deleteById(teacherId);
    }

    /**
     * 修改教师的个人信息
     * @param teacher
     * @return
     */
    @Override
    public int update(Teacher teacher) {
        return teacherMapper.update(teacher);
    }

    /**
     * 添加教师
     * @param teacher
     * @return
     */
    @Override
    public int add(Teacher teacher) {
        return teacherMapper.add(teacher);
    }
}
